% Make Train Data Extract Feature Vectors
clc;
clearvars;
TotalDataFileName='Data\TestDataset_Params.mat';
SubjectNums=1000;
Runs=1:12;
RunNum=length(Runs);
SetNum=12;
TotalSubjectNums=SubjectNums*RunNum;

Params= zeros(TotalSubjectNums,8,SetNum);
ObserverRngState= cell(TotalSubjectNums,SetNum);
ParamsNeam={'W','Alpha1','Alpha2','Beta1','Beta2','Lambda','P1','P2'};
%                   W   Alpha1  Alpha2  Beta1	Beta2	Lambda  P1  P2
ParamsIndex      = [1   1       0       1       0       0       0   0   %Daw3ParamV1
                    1   1       0       1       0       0       0   0   %Daw3ParamV2
                    1   1       0       1       0       1       0   0   %Daw4Param
                    1   1       1       1       1       0       0   0   %Daw5ParamV1
                    1   1       1       1       1       0       0   0   %Daw5ParamV2
                    1   1       1       1       1       1       0   0   %Daw6Param
                    1   1       1       1       1       1       1   0   %Daw7ParamV1
                    1   1       1       1       1       1       1   0   %Daw7ParamV2
                    1   1       1       1       1       1       1   1]; %Daw8Param

ParamNum=(sum(ParamsIndex,2))';
ParamNumMat=repmat(ParamNum,SubjectNums,1);
NR=zeros(SubjectNums,1);
tic
k=0;
PartBestFittedW=zeros(SubjectNums,2);
PartBestFittedAlpha=zeros(SubjectNums,2);
PartBestFittedBeta=zeros(SubjectNums,2);
NoiseRatio=zeros(SetNum,1);
for R=1:RunNum
    for S=1:SetNum
        fprintf('|Run %d |Set %d|\n',R,S)
        DataFileName=['Data\Test_FittingData_Part',num2str(S),'Run',num2str(Runs(R)),'.mat'];
        Data=load(DataFileName);
        Params((k+1):(k+SubjectNums),:,S) = Data.Params;
        for i=(k+1):(k+SubjectNums)
        ObserverRngState{i,S}=Data.ObserverRngState;
        end
    end
        k=k+SubjectNums;
end
save(TotalDataFileName,'Params','ObserverRngState','ParamsNeam','NoiseRatio')
fprintf('\nFinish\n\n')